from langchain_openai import ChatOpenAI

from config import settings

if __name__ == '__main__':

    print(settings.api_key)

    import os

    from langchain_core.messages import HumanMessage, SystemMessage
    from langchain_core.output_parsers import StrOutputParser



    # model = QianfanChatEndpoint(model="ERNIE-Speed-128K")
    llm = ChatOpenAI(model=settings.llm_name, api_key=settings.api_key,base_url=settings.llm_url)
    # 准备提示词
    msg = [
        SystemMessage(content='请将以下的内容翻译成英语'),
        HumanMessage(content="你好，请问你要去哪里"),
    ]
    # 执行
    result = llm.invoke(msg)
    parser = StrOutputParser()
    result_parser = parser.invoke(result)
    # 执行的result_parser结果如下：
    print(result_parser)